package com.prolestar.web.controller.strategy;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.prolestar.common.annotation.Log;
import com.prolestar.common.core.controller.BaseController;
import com.prolestar.common.core.domain.AjaxResult;
import com.prolestar.common.core.page.TableDataInfo;
import com.prolestar.common.enums.BusinessType;
import com.prolestar.common.utils.poi.ExcelUtil;
import com.prolestar.strategy.domain.PsPublicsentimentStrategy;
import com.prolestar.strategy.domain.PsPublicsentimentStrategyVO;
import com.prolestar.strategy.service.IPsPublicsentimentStrategyService;
import com.prolestar.util.MySetPage;

/**
 * 应对策略Controller
 *
 * @author xuyp
 * @date 2022-11-12
 */
@RestController
@RequestMapping("/strategy/strategy")
public class PsPublicsentimentStrategyController extends BaseController
{
    @Autowired
    private IPsPublicsentimentStrategyService psPublicsentimentStrategyService;

    /**
     * 查询应对策略列表
     */
    @PreAuthorize("@ss.hasPermi('strategy:strategy:list')")
    @GetMapping("/list")
    public TableDataInfo list(PsPublicsentimentStrategy psPublicsentimentStrategy)
    {
//        startPage();
        List<PsPublicsentimentStrategyVO> list = psPublicsentimentStrategyService.selectPsPublicsentimentStrategyList(psPublicsentimentStrategy);
//        return getDataTable(list);
        return MySetPage.mySetPage(list);
    }

    /**
     * 导出应对策略列表
     */
    @PreAuthorize("@ss.hasPermi('strategy:strategy:export')")
    @Log(title = "应对策略", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PsPublicsentimentStrategy psPublicsentimentStrategy)
    {
        List<PsPublicsentimentStrategyVO> list = psPublicsentimentStrategyService.selectPsPublicsentimentStrategyList(psPublicsentimentStrategy);
        ExcelUtil<PsPublicsentimentStrategyVO> util = new ExcelUtil<PsPublicsentimentStrategyVO>(PsPublicsentimentStrategyVO.class);
        util.exportExcel(response, list, "应对策略数据");
    }

    /**
     * 获取应对策略详细信息
     */
    @PreAuthorize("@ss.hasPermi('strategy:strategy:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(psPublicsentimentStrategyService.selectPsPublicsentimentStrategyById(id));
    }

    /**
     * 新增应对策略
     */
    @PreAuthorize("@ss.hasPermi('strategy:strategy:add')")
    @Log(title = "应对策略", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PsPublicsentimentStrategy psPublicsentimentStrategy)
    {
        return toAjax(psPublicsentimentStrategyService.insertPsPublicsentimentStrategy(psPublicsentimentStrategy));
    }

    /**
     * 修改应对策略
     */
    @PreAuthorize("@ss.hasPermi('strategy:strategy:edit')")
    @Log(title = "应对策略", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PsPublicsentimentStrategy psPublicsentimentStrategy)
    {
        return toAjax(psPublicsentimentStrategyService.updatePsPublicsentimentStrategy(psPublicsentimentStrategy));
    }

    /**
     * 删除应对策略
     */
    @PreAuthorize("@ss.hasPermi('strategy:strategy:remove')")
    @Log(title = "应对策略", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(psPublicsentimentStrategyService.deletePsPublicsentimentStrategyByIds(ids));
    }
}
